<template>

    <div class="section_common">
        <div class="main">
            <el-form ref="form" label-width="100px">
                <el-form-item label="入职日期">
                    <el-input v-model="entryDate" size="mini"></el-input>
                </el-form-item>

                <el-form-item label="工号">
                    <el-input v-model="jobnum" size="mini"></el-input>
                </el-form-item>
                <el-form-item label="姓名">
                    <el-input v-model="user" size="mini"></el-input>
                </el-form-item>
                <el-form-item label="部门名">
                    <el-input v-model="deptName" size="mini"></el-input>
                </el-form-item>
                <el-form-item label="消息周期">
                    <el-input v-model="cycle" size="mini"></el-input>
                </el-form-item>
                <el-form-item label="工作描述">
                    <el-input type="textarea" v-model="uconcent" size="mini"></el-input>
                </el-form-item>

                <el-form-item>
                    <el-button v-bind:disabled="isShow" type="primary" size="mini" @click="submitPost"
                    >{{message}}</el-button
                    >
                </el-form-item>

            </el-form>
        </div>
    </div>


</template>
<script>
    import Vue from 'vue';
    import {Toast,Picker,Popup,Dialog} from 'vant';
    Vue.use(Picker);
    Vue.use(Popup);
    Vue.use(Dialog)



    export default {

        data() {
            return {
                id:"",//入职管理对应的id
                thiid:"",//入职30天表数据对应的id
                entryDate: "",//入职时间
                jobnum:"",
                user:"",//用户名
                deptName:"",
                cycle:"",//消息周期
                uconcent:"",//用户填写内容

                title: "销售部入职管理",
                editManagement: '/mobiles/editThiManagement',

                isShow:false,
                message:"提交",

        };
        },

        created() {
            this.nowUser=JSON.parse(localStorage.getItem('userInfo')).userId;
            this.id= this.$route.params.id;
            this.getManagementInfo();
        },

        methods: {

            //根据入职管理的id找到相对应的入职管理详情
            getManagementInfo(){
                this.$https.post('/mobiles/getManagementInfo',{
                    nowUser:this.nowUser,
                    id:this.id
                }).then((res)=>{
                    console.log(res.data.data);
                    this.entryDate=res.data.data.entryDate;
                    this.jobnum=res.data.data.jobnum;
                    this.user=res.data.data.user;
                    this.deptName=res.data.data.deptName;
                    this.cycle=res.data.data.cycle;
                    this.thiid=res.data.data.thiid;
                    this.uconcent=res.data.data.uconcent;
                    if (res.data.data.thiSubmit=='0'){
                        this.isShow=true;
                        this.message="已填写";
                    }
                }).catch(err => {
                    console.log(err);
                })
            },

            // 返回
            goBack() {
                this.$router.go(-1);
            },
            // 提交
            submitPost() {
                if (!this.isNull()) return false;

                this.$https.post(this.editManagement, {
                    userId:this.nowUser,
                    id:this.thiid,
                    uconcent: this.uconcent

                }).then(() => {
                    Toast("推送成功");
                    this.isShow=true;
                    this.message="已提交";
                    //this.$router.go(-1);
                }).catch(err => {
                    console.log(err)
                });
            },
            //判断相关数据是否为空
            isNull() {
                if (this.uconcent == '') {
                    this.$toast("请填写内容");
                    return false;
                }

                return true;
            },

        },
    };
</script>

<style lang="scss" scoped>
    .main {
        background-color: white;
        .el-form {
            padding-right: 10px;
            .el-form-item {
                .el-form-item__label {
                    line-height: 16px;
                }
                margin-bottom: 5px;
            }
        }
    }
</style>
